package com.ruoyi.web.controller.tool;

public class WlyzToHexStringUtils {

    public static String bytesToHexString(byte[] bytes) {
        StringBuilder sb = new StringBuilder();
        for (byte b : bytes) {
            sb.append(String.format("%02X", b)); // 格式化为两位十六进制
        }
        return sb.toString();
    }

    public static void main(String[] args) throws Exception {
        byte[] MemoryBytes1 = new byte[] {
                (byte) 0xFA, (byte) 0x02, (byte) 0x72, (byte) 0x48,
                (byte) 0x83, (byte) 0xF8, (byte) 0x02, (byte) 0x0F,
                (byte) 0x85, (byte) 0xF9, (byte) 0x0A, (byte) 0x00,
                (byte) 0x00, (byte) 0x85, (byte) 0xC9, (byte) 0x74
        };
        String key = "a1b2c3d4"; // 密钥必须是8字节
        String hexString = bytesToHexString(MemoryBytes1);
        String DesHexString = DesUtil.encrypt(key, hexString);
        System.out.println("DesHexString: " + DesHexString); // 输出十六进制字符串
        System.out.println("Hex String: " + hexString); // 输出十六进制字符串
    }

}
